package com.manlu.controller;

import com.manlu.service.CategoryService;
import com.manlu.vo.BaseResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Auther 漫路h
 * Created by 2020-05-14 16:05
 */
@RestController
@RequestMapping("/category")
public class CategoryController {
    @Resource
    private CategoryService categoryService;

    /**
     * 根据分类id查询分类
     * @param cid 分类id
     * @return
     */
    @GetMapping("/selectCategoryByCid/{cid}")
    public BaseResult selectCategoryChildByCid(@PathVariable Integer cid){
        return categoryService.selectCategoryChildByCid(cid);
    }


    /**
     * 根据分类级别查询分类
     * @param level 分类级别
     * @return
     */
    @GetMapping("/{level}")
    public BaseResult selectCategoryAllByLevel(@PathVariable String level){
        return categoryService.selectCategoryAllByLevel(level);
    }

}
